package pointersandreferences;

import java.util.Date;


public class CallbyRefValue {

	private static final Date DATE = new Date();
	
	public static void main(String[] args) {
		String abc = "123";
		System.out.println("Before Experiment1: " + abc);
		foo(abc);
		System.out.println("After Experiment1 : " + abc);
		
		abc = foo(abc);
		System.out.println("After Experiment2 : " + abc);
		
		Date d = DATE;
		System.out.println("\n\nBefore Experiment1: " + d.getTime());
		fooDate(d);
		System.out.println("After Experiment1: " + d.getTime());
		
		d = fooDate(d);
		System.out.println("After Experiment2: " + d.getTime());
		
		System.out.println("Before Experiment3: " + d);
		barDate(d);
		System.out.println("After Experiment3: " + d);
	}
	
	static String foo(String xyz) {
		xyz = xyz + "pqr";
		System.out.println(xyz);
		return xyz;
	}
	
	static Date fooDate(Date ddash) {
		ddash = new Date();
		System.out.println("During: " + ddash.getTime());
		return ddash;
	}
	
	@SuppressWarnings("deprecation")
	static void barDate(Date d) {
		d.setYear(2000);
	}
	
}
